<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>文档</title>
  <link href="../css/semantic/semantic.min.css" rel="stylesheet">
  <link href="../css/markdown.css" rel="stylesheet">
  <link href="../css/wtxynavigation.css" rel="stylesheet">
  <script src="../js/jquery.min.js"></script>
  <script type="text/javascript" src="../js/include.js"></script>
  <style>
    body{padding-top:0;background:#f7f7f7}
    body>.ui.container{width:100%;padding:0}
    #project-title{background:#6e6e6e;width:100%;line-height:3.572rem;color:#fff;font-size:1.2rem}
    #project-title .title-wrap{font-weight:700;padding:0 12px;width:100%;max-width:1366px!important;min-width:900px;margin:0 auto}
    #project-title .left,#project-title right{display:inline-block}
    #project-title .right{float:right}
    #project-title .right .wiki-actions .menu{left:auto;right:0;margin-top:.4em!important}
    #wiki-preview-container{width:100%;max-width:1366px!important;min-width:900px;padding:0;border:1px solid #e3e9ed;border-top:0}
    #wiki-preview>.ui.segment{margin-top:0;padding:1rem;padding-left:0;border:0}
    .hover-places{display:inline-block}
    #page-detail{width:60%;margin:0 auto}
    #page-detail .title{font-weight:700;font-size:24px;padding:12px 0;border-bottom:1px solid #ccc}
    #page-detail .content{margin-top:15px}
    .content p{word-wrap:break-word}
    #wiki-parent,#wiki-title,#wikis{display:none}
    .ui.grid{padding:0!important}
    #ex-all{cursor:pointer;color:#537c8d}
  </style>
</head>
<body>
  <div class="ui container">
    <div id="project-title">
      <div class="title-wrap">
        <div class="left">
          <i class="icon eye"></i>
          文档预览:
          mianmSDK
        </div>
        <div class="right">
          Export by Gitee
        </div>
      </div>
    </div>

    <div class="ui container" id="wiki-preview-container">
      <div id="wiki-preview">
        <div class="ui segment">
          <div id="page-detail" class="markdown-body">
            <div class='title'>22.多线程小结</div><div class='content'><h1>
<a id="多线程小结" class="anchor" href="#%E5%A4%9A%E7%BA%BF%E7%A8%8B%E5%B0%8F%E7%BB%93"></a>多线程小结</h1>
<p><strong>关键词</strong>:</p>
<h1>
<a id="1-怎样用gcd实现多度单写" class="anchor" href="#1-%E6%80%8E%E6%A0%B7%E7%94%A8gcd%E5%AE%9E%E7%8E%B0%E5%A4%9A%E5%BA%A6%E5%8D%95%E5%86%99"></a>1. 怎样用GCD实现多度单写?</h1>
<h1>
<a id="答--使用dispatch_barrier_async" class="anchor" href="#%E7%AD%94--%E4%BD%BF%E7%94%A8dispatch_barrier_async"></a>答:  使用<code>dispatch_barrier_async</code>
</h1>
<ol>
<li>在读端使用 同步+并发队列</li>
<li>在写端使用 <code>dispatch_barrier_async</code> + 并发队列</li>
</ol>
<h1>
<a id="2-ios系统为我们提供了几种多线程技术各自特点是" class="anchor" href="#2-ios%E7%B3%BB%E7%BB%9F%E4%B8%BA%E6%88%91%E4%BB%AC%E6%8F%90%E4%BE%9B%E4%BA%86%E5%87%A0%E7%A7%8D%E5%A4%9A%E7%BA%BF%E7%A8%8B%E6%8A%80%E6%9C%AF%E5%90%84%E8%87%AA%E7%89%B9%E7%82%B9%E6%98%AF"></a>2. iOS系统为我们提供了几种多线程技术各自特点是?</h1>
<h1>
<a id="答" class="anchor" href="#%E7%AD%94"></a>答:</h1>
<ol>
<li>主要提供了三种<code>NSThread</code>,<code>NSOperation</code>, <code>GCD</code>
</li>
<li>
<code>NSThread</code>常驻线程, 简单的线程同步,子线程分派, 多度单写</li>
<li>
<code>NSOperation</code>,在<strong>AFNetworking</strong>,<strong>SDWebImage</strong>里面用, 它可以对任务状态进行控制</li>
</ol>
<h1>
<a id="3-nsoperation里系统是怎样移除一个isfinished为yes的nsoperation的" class="anchor" href="#3-nsoperation%E9%87%8C%E7%B3%BB%E7%BB%9F%E6%98%AF%E6%80%8E%E6%A0%B7%E7%A7%BB%E9%99%A4%E4%B8%80%E4%B8%AAisfinished%E4%B8%BAyes%E7%9A%84nsoperation%E7%9A%84"></a>3. NSOperation里系统是怎样移除一个isFinished为YES的NSOperation的?</h1>
<h1>
<a id="答-内部通过kvo的方式" class="anchor" href="#%E7%AD%94-%E5%86%85%E9%83%A8%E9%80%9A%E8%BF%87kvo%E7%9A%84%E6%96%B9%E5%BC%8F"></a>答: 内部通过KVO的方式</h1>
<h1>
<a id="4-ios中都有哪些锁-这些锁怎么用的使用场景是" class="anchor" href="#4-ios%E4%B8%AD%E9%83%BD%E6%9C%89%E5%93%AA%E4%BA%9B%E9%94%81-%E8%BF%99%E4%BA%9B%E9%94%81%E6%80%8E%E4%B9%88%E7%94%A8%E7%9A%84%E4%BD%BF%E7%94%A8%E5%9C%BA%E6%99%AF%E6%98%AF"></a>4. iOS中都有哪些锁? 这些锁怎么用的,使用场景是?</h1>
<h1>
<a id="答-见详情" class="anchor" href="#%E7%AD%94-%E8%A7%81%E8%AF%A6%E6%83%85"></a>答: 见详情</h1>
<h1>
<a id="1" class="anchor" href="#1"></a>1.</h1>
<h1>
<a id="答-1" class="anchor" href="#%E7%AD%94-1"></a>答:</h1></div>
          </div>
        </div>
      </div>
      </div>
  </div>
</body>
</html>